package com.wb.server.processor.impl;

import com.wb.server.processor.DataProcessorFactory;
import com.wb.server.processor.ServerFactory;
import com.wb.server.tcp.server.AbstractIecServer;
import com.wb.server.tcp.server.TcpIecServer;
import com.wb.server.udp.server.UdpCollectServer;
import com.wb.tcp.common.utils.ServerType;

import java.util.Calendar;

/**
 * @Author chenyong
 * @Description TODO
 * @Date 2022/12/15 9:39
 * @Version 1.0
 */
public final class ServerFactoryImpl implements ServerFactory {
    @Override
    public void startServer(int port,ServerType serverType, DataProcessorFactory dataProcessorFactory) {
        AbstractIecServer server=null;
        if(serverType.equals(ServerType.TCP)){
            server= new TcpIecServer(dataProcessorFactory);
        }else if(serverType.equals(ServerType.UDP)){
            server =new UdpCollectServer(dataProcessorFactory);
        }
        if(server!=null){
            server.startServer(port);
        }


    }
}
